# encoding: utf-8

import pyautogui
import time
import win32gui
import win32con
import sys
import os
import time
import pyautogui
import win32api
import win32con
import win32gui
import win32print
sys.path.append("../")
from utils.MouseUtil import *
from utils.KeyBoardUtil import *

class UI:
    def __init__(self):
        pass

    @classmethod
    def start(self):
        '''
        time.sleep(10)
        return True
        '''
        time.sleep(5)
        hid = win32gui.WindowFromPoint((0, 0))
        # 获取窗口标题
        title = win32gui.GetWindowText(hid)
        self.__wincurhd = win32gui.FindWindow(None, title)
        win32gui.ShowWindow(self.__wincurhd, win32con.SW_MINIMIZE)
        UI.setScreen()

    @classmethod
    def setScreen(cls):
        dm = win32api.EnumDisplaySettings(None, 0)
        dm.PelsHeight = 1080
        dm.PelsWidth = 1920
        dm.BitsPerPel = 32
        dm.DisplayFixedOutput = 0
        win32api.ChangeDisplaySettings(dm, 0)

    @classmethod
    def setWindowMax(cls,title=""):
        if title == "":
            hid = win32gui.WindowFromPoint((0, 0))
            # 获取窗口标题
            title = win32gui.GetWindowText(hid)
        wincurhd = win32gui.FindWindow(None, title)
        win32gui.ShowWindow(wincurhd, win32con.SW_MAXIMIZE)

    @classmethod
    def sleep(self,second):
        time.sleep(second)

    @classmethod
    def debug(self,msg):
        print(msg)

    @classmethod
    def catDestok(cls):
        UI.sleep(1)
        #隐藏同花顺窗口
        MouseUtil.click(1551,1061,"right")
        UI.sleep(2)
        KeyBoardUtil.twoHot("ctrl","S")

    @classmethod
    def end(self):
        '''
        return True
        '''
        time.sleep(5)
        win32gui.ShowWindow(self.__wincurhd, win32con.SW_MAXIMIZE)


    @classmethod
    def exit(cls):
        print("process exit!")
        sys.exit(0)

    @classmethod
    def getCurrentTitle(cls):
        hid = win32gui.WindowFromPoint((0, 0))
        # 获取窗口标题
        return win32gui.GetWindowText(hid)